package nl.dds.sandr.LoesjeOfTheDay;

import java.io.BufferedInputStream ;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;

public class LoesjeOfTheDayView extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        HttpURLConnection urlConnection = null;
        try {
          URL url = new URL("http://www.loesje.nl/pix/hlactie.gif");
          urlConnection = (HttpURLConnection) url.openConnection();
          BufferedInputStream bis = new BufferedInputStream(urlConnection.getInputStream());
          Bitmap bmp = BitmapFactory.decodeStream(bis);
          ImageView i = (ImageView) findViewById(R.id.imageView1);
          i.setImageBitmap(bmp);
        } catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();         
        } catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
          urlConnection.disconnect();
        }        

    }
}